package com.baiku.sanhos.utils.model.util;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.io.*;
@Component
public class CreateNewFile {
    /**
     * 输出新文件路径及名称
     */
    @Value("${itemInventoryPath}")
    private String WRITE_FILE;

    public BufferedOutputStream create(String username,Object date) throws IOException {
        File file = new File(WRITE_FILE+username+"_"+date.toString()+".xlsx");
        File parentDir = file.getParentFile();
        if (!parentDir.exists()) {
            parentDir.mkdirs();
        }
        FileOutputStream fos = new FileOutputStream(file);
        return new BufferedOutputStream(fos);
    }
}
